package _220315;

import java.util.HashSet;
import java.util.Set;

/**
 * @author ShadowLim
 * @create 2022-03-15-12:18
 */
public class _神奇算式 {
    static int cnt = 0;
    static int[] arr = {1,2,3,4,5,6,7,8,9};

    public static void main(String[] args) {
        for (int i = 0; i < 999; i++) {
            for (int j = 0; j < 999; j++) {
                if (check(i, j)) {
                    cnt++;
                }
            }
        }
        System.out.println(cnt / 2);
    }

    private static boolean check(int i, int j) {
        int ans = i * j;
        Set<Integer> set = new HashSet<>();
        while (i != 0) {
            // 条件一：四个数字互不相同
            if (set.contains(i % 10)) {
                return false;
            } else {
                set.add(i % 10);
            }
            i /= 10;
        }
        while (j != 0) {
            if (set.contains(j % 10)) {
                return false;
            } else {
                set.add(j % 10);
            }
            j /= 10;
        }
        if (set.size() != 4) {
            return false;
        }
        while (ans != 0) {
            int a = ans % 10;
            if (!set.contains(a)) {
                return false;
            } else {
                set.remove(a);
            }
            ans /= 10;
        }
        return set.size() == 0;
    }
}
